<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <head th:replace="common/head"/>
</head>
<body>
<div class="x-body">
    <form class="layui-form layui-form-pane">
        <input type="hidden" name="id" th:value="${myEntity.id}">
        <input type="hidden" id="hideValue" th:value="${myEntity.content}">

        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-block">
                <input type="text" name="title" lay-verify="required" th:value="${myEntity.title}" placeholder="必填" autocomplete="off" class="layui-input">
            </div>
        </div>
        <input type="hidden" id='content' name="content">
        <div id="editor">

        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" style="margin-left:200px;" lay-submit lay-filter="specialSubmit">提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<div th:replace="common/js"></div>
<div th:replace="common/setting"></div>
<script type="text/javascript">
    var E = window.wangEditor
    var editor = new E('#editor')
    editor.create();
    var valueShow=document.getElementById('hideValue').value;
    editor.txt.html(valueShow);
    layui.use(['layer', 'form'], function(){
        var $ = layui.jquery,
            form = layui.form;
        form.on('submit(specialSubmit)', function(data){
            let values = data.field
            values.content = editor.txt.html();
            $.post('/customerText/doEdit', values, function (result) {
                if (result.code == 0) {
                    layer.msg(result.msg, {
                        icon: 1,
                        time: 1000
                    });
                    parent.layui.table.reload('table');
                    let index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                } else {
                    layer.msg(result.msg, {
                        icon: 2,
                    });
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
